﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dtl;
using System.Data.Common;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using System.Resources;
using System.ComponentModel;
using System.IO;
using System.Configuration;


namespace Dal
{
    public class CabinetInventoryDao
    {
        public static DataSet getCabinetInventoryReport(string distributor, string ambient)
        {

            string connection = Credentials.getCredentias(ambient);
            if (connection == null)
            {
                return null;
            }

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = new SqlConnection(connection);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.CommandText = "dbo.dms_Report_ImportCabinetInventory";
            cmd.Parameters.AddWithValue("@idDistributor", distributor);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dtVisit = new DataTable("Cabinetdt");

            try
            {
                cmd.Connection.Open();
                da.Fill(dtVisit);
                cmd.Connection.Close();
            }
            catch (Exception ex)
            {
                Credentials.writeLogFile("getCabinetInventoryReport: " + ex.Message);                
                return null;
            }
            DataSet ds = new DataSet("Cabinetds");
            ds.Tables.Add(dtVisit);


            return ds;

        }

    }
}
